package com.smarthealthcare.patient.service.impl;

import java.util.List;

import com.smarthealthcare.domain.Register;
import com.smarthealthcare.mapper.RegisterMapper;
import com.smarthealthcare.ward.domain.Ward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smarthealthcare.patient.mapper.BeinhospitalMapper;
import com.smarthealthcare.patient.domain.Beinhospital;
import com.smarthealthcare.patient.service.IBeinhospitalService;
import com.smarthealthcare.ward.mapper.WardMapper;

/**
 * 病房列表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@Service
public class BeinhospitalServiceImpl implements IBeinhospitalService 
{
    @Autowired
    private BeinhospitalMapper beinhospitalMapper;
    @Autowired
    private WardMapper wardMapper;
    @Autowired
    private RegisterMapper registerMapper;

    /**
     * 查询病房列表
     * 
     * @param id 病房列表主键
     * @return 病房列表
     */
    @Override
    public Beinhospital selectBeinhospitalById(Long id)
    {
        return beinhospitalMapper.selectBeinhospitalById(id);
    }

    /**
     * 查询病房列表列表
     * 
     * @param beinhospital 病房列表
     * @return 病房列表
     */
    @Override
    public List<Beinhospital> selectBeinhospitalList(Beinhospital beinhospital)
    {

        List<Beinhospital> list = beinhospitalMapper.selectBeinhospitalList(beinhospital);
        for (Beinhospital beinhospital1:list) {
            Long wardId = beinhospital1.getWardId();
            Ward ward = wardMapper.selectWardById(wardId);
            beinhospital1.setWard(ward);
            Long patientId = beinhospital1.getPatientId();
            Register register = registerMapper.selectRegisterById(patientId);
            beinhospital1.setRegister(register);
        }
        return list;
    }

    /**
     * 新增病房列表
     * 
     * @param beinhospital 病房列表
     * @return 结果
     */
    @Override
    public int insertBeinhospital(Beinhospital beinhospital)
    {
        return beinhospitalMapper.insertBeinhospital(beinhospital);
    }

    /**
     * 修改病房列表
     * 
     * @param beinhospital 病房列表
     * @return 结果
     */
    @Override
    public int updateBeinhospital(Beinhospital beinhospital)
    {
        return beinhospitalMapper.updateBeinhospital(beinhospital);
    }

    /**
     * 批量删除病房列表
     * 
     * @param ids 需要删除的病房列表主键
     * @return 结果
     */
    @Override
    public int deleteBeinhospitalByIds(Long[] ids)
    {
        return beinhospitalMapper.deleteBeinhospitalByIds(ids);
    }

    /**
     * 删除病房列表信息
     * 
     * @param id 病房列表主键
     * @return 结果
     */
    @Override
    public int deleteBeinhospitalById(Long id)
    {
        return beinhospitalMapper.deleteBeinhospitalById(id);
    }
}
